package com.hemaapp.yjnh.bean;

import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.android.uu.utils.uuUtils;

import xtom.frame.XtomObject;
import xtom.frame.exception.DataParseException;

/**我的足迹 用户访问记录
 * @author GuiyouZhang
 * Date：2015年12月31日 下午5:08:57
 * Email:guiyouzhang@163.com
 */
public class Footprint extends XtomObject implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private String farmer_id;// 田家id	用于点击进入田家详情
	private String seller_id;// 商家id	用于点击进入商家详情
	private String nickname;// 田家名称/商家名称	
	private String starscore;// 星数	
	private String avatar;// 头像	
	private String price;// 商家起价/商品价格	
	private String mu_num;// 土地亩数	
	private String land_id;// 土地主键	
	private String good_names;// 作物种类	
	private String blog_id;// 商品id	用于点击进入商品详情
	private String blog_name;// 商品名称	
	private String oldprice;// 商品原价
    private String score;// 商品可用粮票
	private String sellcount;// 商品销量	
	private String imgurl;// 商品缩略图
	private String imgurlbig;// 商品大图
	private String distance;//	距离
	private String type;// 商品类型	2有机；3地标；4村游；5田家日志；6特产；9乐乐；11粮库；
	//71走走房车露营；72走走自驾车露营；73走走帐篷露营；74走走商品区；75走走房车；81苗木；82花卉；83家电；84日用品；
	private String isChecked;

    private ArrayList<FarmerImgItems> farmerImgItemses = new ArrayList<>();
	
	public Footprint(JSONObject jsonObject) throws DataParseException {
		if (jsonObject != null) {
			try {
				farmer_id = get(jsonObject, "farmer_id");
				seller_id = get(jsonObject, "seller_id");
				nickname = get(jsonObject, "nickname");
				starscore = get(jsonObject, "starscore");
				avatar = get(jsonObject, "avatar");
				price = uuUtils.formatAfterDot2(get(jsonObject, "price"));
				oldprice = uuUtils.formatAfterDot2(get(jsonObject, "oldprice"));
				mu_num = get(jsonObject, "mu_num");
				land_id = get(jsonObject, "land_id");
				good_names = get(jsonObject, "good_names");
				blog_id = get(jsonObject, "blog_id");
				blog_name = get(jsonObject, "blog_name");
				sellcount = get(jsonObject, "sellcount");
				distance = get(jsonObject, "distance");
				imgurlbig = get(jsonObject, "imgurlbig");
				imgurl = get(jsonObject, "imgurl");
				type = get(jsonObject, "type");
                score = uuUtils.formatAfterDot2(get(jsonObject, "score"));
                if (!jsonObject.isNull("farmerImgItems")
                        && !isNull(jsonObject.getString("farmerImgItems"))) {
                    JSONArray gObj = jsonObject.getJSONArray("farmerImgItems");
                    for (int i = 0; i < gObj.length(); i++) {
                        farmerImgItemses.add(new FarmerImgItems((JSONObject) gObj.get(i)));
                    }
                }
				log_i(toString());
			} catch (JSONException e) {
				throw new DataParseException(e);
			}
		}
	}

    public String getScore() {
        return score;
    }

    public String getFarmer_id() {
		return farmer_id;
	}

	public String getSeller_id() {
		return seller_id;
	}

	public String getNickname() {
		return nickname;
	}

	public String getStarscore() {
		return starscore;
	}

	public String getAvatar() {
		return avatar;
	}

	public String getPrice() {
		return price;
	}

	public String getMu_num() {
		return mu_num;
	}

	public String getLand_id() {
		return land_id;
	}

	public String getGood_names() {
		return good_names;
	}

	public String getBlog_id() {
		return blog_id;
	}

	public String getBlog_name() {
		return blog_name;
	}

	public String getOldprice() {
		return oldprice;
	}

	public String getSellcount() {
		return sellcount;
	}

	public String getImgurl() {
		return imgurl;
	}

	public String getImgurlbig() {
		return imgurlbig;
	}

	public String getIsChecked() {
		return isChecked;
	}

	public void setIsChecked(String isChecked) {
		this.isChecked = isChecked;
	}

	public String getType() {
		return type;
	}

	public String getDistance() {
		return distance;
	}

    public ArrayList<FarmerImgItems> getFarmerImgItemses() {
        return farmerImgItemses;
    }

    public class FarmerImgItems extends XtomObject implements Serializable {

        private String id;
        private String client_id;
        private String content;
        private String imgurl;
        private String imgurlbig;
        private String orderby;

        public FarmerImgItems(JSONObject jsonObject) throws DataParseException {
            if (jsonObject != null) {
                try {
                    id = get(jsonObject, "id");
                    client_id = get(jsonObject, "client_id");
                    content = get(jsonObject, "content");
                    imgurl = get(jsonObject, "imgurl");
                    imgurlbig = get(jsonObject, "imgurlbig");
                    orderby = uuUtils.formatAfterDot2(get(jsonObject, "orderby"));
                } catch (JSONException e) {
                    throw new DataParseException(e);
                }
            }
        }

        public String getId() {
            return id;
        }

        public String getClient_id() {
            return client_id;
        }

        public String getContent() {
            return content;
        }

        public String getImgurl() {
            return imgurl;
        }

        public String getImgurlbig() {
            return imgurlbig;
        }

        public String getOrderby() {
            return orderby;
        }
    }
}
